#include <stdio.h>
#include <stdlib.h>
#include <string.h>


typedef struct Paper
{
    char * teacher_name;
    int class;
    char *question;
    struct Paper* (*copy)(struct Paper* pPaper);

}paper;

/*原型复制接口*/

paper* paper_copy(paper * pPaper)
{
    paper* copy=(paper*)malloc(sizeof(paper));
    memcpy(copy,pPaper,sizeof(paper));
    return copy;
}

paper* clone(paper* pPaper)
{
    return pPaper->copy(pPaper);
}


int main()
{
    //定义原型
    paper paperPrototype;
    paperPrototype.teacher_name="wang";
    paperPrototype.class=3;
    paperPrototype.question="1+1=?";
    paperPrototype.copy=paper_copy;

    for (int i=0;i<=10;i++)
    {
        paper* tmppaper=clone(&paperPrototype);
        printf("paper_%d=>name:%s,class:%d,question:%s\r\n",i,\
               tmppaper->teacher_name,\
               tmppaper->class,tmppaper->question);
        free(tmppaper) ;
    }

}
